/**
 * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springblade.modules.system.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springblade.modules.system.entity.Drugs;

import org.springblade.modules.system.mapper.DrugsMapper;

import org.springblade.modules.system.service.IDrugsService;

import org.springblade.utils.PageBounds;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 服务实现类
 *
 * @author Chill
 */
@Service
public class DrugsServiceImpl extends ServiceImpl<DrugsMapper, Drugs> implements IDrugsService {

	@Override
	public int addDrugs(Drugs drugs) {
		return baseMapper.addDrugs(drugs);
	}

	@Override
	public int deleteDrugs(int id) {
		return baseMapper.deleteDrugs(id);
	}

	@Override
	public int updateDrugs(Drugs drugs) {
		return baseMapper.updateDrugs(drugs);
	}

	@Override
	public PageBounds<Drugs> showAllDrugs(Drugs drugs, int currentPage, int pageSize) {
		final int totalSize = baseMapper.getAllDrugsCount(drugs);
		PageBounds<Drugs> pageBounds = new PageBounds<>(currentPage, totalSize, pageSize);
		List<Drugs> list = baseMapper.showAllDrugs(drugs, pageBounds.getOffset(), pageBounds.getPageSize());
		pageBounds.setPageList(list);
		return pageBounds;
	}


	@Override
	public Drugs findByDrugsId(Integer id) {
		return baseMapper.findByDrugsId(id);
	}

	@Override
	public int deleteMoreDrugs(List<Integer> ids) {
		return baseMapper.deleteMoreDrugs(ids);
	}
}
